using System;
using Data;
using TMPro;
using UnityEngine;

public class PictureThemeWidgetHandler : MonoBehaviour, IWidget, IHandlerBase
{
	public void SetData(string _name)
	{
		this.themeName = _name;
		this.name.text = StringExt.UppercaseFirst(this.themeName);
		this.SetUI();
	}

	public void DoDataExchange()
	{
	}

	private void SetUI()
	{
		this.newIcon.SetActive(false);
		this.clearCount = 0;
		this.totalCount = 0;
		bool flag = false;
		for (int i = 0; i < DataContainer<Data.Root>.Data.packages.Length; i++)
		{
			for (int j = 0; j < DataContainer<Data.Root>.Data.packages[i].levels.Length; j++)
			{
				if (!string.IsNullOrEmpty(DataContainer<Data.Root>.Data.packages[i].levels[j].pictureTheme) && this.themeName.Equals(DataContainer<Data.Root>.Data.packages[i].levels[j].pictureTheme))
				{
					this.totalCount++;
					if (DataContainer<Data.Root>.Data.packages[i].levels[j].record.isNewCollection)
					{
						flag = true;
					}
					if (DataContainer<Data.Root>.Data.packages[i].levels[j].record.isClear)
					{
						this.clearCount++;
					}
				}
			}
		}
		if (flag)
		{
			this.newIcon.SetActive(true);
		}
		this.progress.Percent = ((this.totalCount > 0) ? ((float)this.clearCount / (float)this.totalCount * 100f) : 0f);
		this.percent.text = string.Format("{0}%", (int)this.progress.Percent);
	}

	public void OnClick_Self(tk2dUIItem obj)
	{
		BMSoundHelper.Play("se_btnclick", false, 1f);
		this.parent = Scene.FindSceneRoot(obj.transform.parent.gameObject);
		this.parent.SendMessage("OnClickTheme", this);
	}

	private GameObject parent;

	public new TextMeshPro name;

	public GameObject newIcon;

	public tk2dProgress progress;

	public TextMeshPro percent;

	public string themeName = string.Empty;

	private int totalCount;

	private int clearCount;
}
